﻿<Application x:Class="LogicCircuit.App"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:lc="clr-namespace:LogicCircuit"
	xmlns:properties="clr-namespace:LogicCircuit.Properties"
	xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
	StartupUri="Mainframe.xaml"
>
	<Application.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="ColorPicker/ColorPicker.xaml"/>
			</ResourceDictionary.MergedDictionaries>

			<lc:DoubleAdderConverter x:Key="DoubleAdderConverter"/>
			<lc:HyperlinkNavigationCommand x:Key="HyperlinkNavigationCommand"/>

			<Style TargetType="Hyperlink">
				<Setter Property="Command" Value="{StaticResource HyperlinkNavigationCommand}"/>
				<Setter Property="CommandParameter" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=NavigateUri}"/>
				<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=NavigateUri}"/>
			</Style>

			<LinearGradientBrush x:Key="WindowBackground" StartPoint="0.25,0" EndPoint="0.75,1" PresentationOptions:Freeze="True">
				<GradientStop Color="{x:Static SystemColors.ControlLightLightColor}" Offset="0"/>
				<GradientStop Color="{x:Static SystemColors.ControlColor}" Offset="1"/>
			</LinearGradientBrush>

			<SolidColorBrush x:Key="MarkerStroke" Color="#FFF505F5" PresentationOptions:Freeze="True"/>

			<LinearGradientBrush x:Key="MarkerFill" StartPoint="0,0" EndPoint="1,1" PresentationOptions:Freeze="True">
				<GradientStop Color="#54AC51AB" Offset="0"/>
				<GradientStop Color="#54F606F5" Offset="0.5"/>
				<GradientStop Color="#54AC51AB" Offset="1"/>
			</LinearGradientBrush>

			<LinearGradientBrush x:Key="LedOff" StartPoint="0,0" EndPoint="1,1" PresentationOptions:Freeze="True">
				<GradientStop Color="#FFCEE3CF" Offset="0"/>
				<GradientStop Color="#FF909090" Offset="1"/>
			</LinearGradientBrush>

			<SolidColorBrush x:Key="LedOn0" Color="#FF5B4949" PresentationOptions:Freeze="True"/>

			<RadialGradientBrush x:Key="LedOn1" PresentationOptions:Freeze="True">
				<GradientStop Color="#FFFF7000" Offset="0"/>
				<GradientStop Color="#FFFB0303" Offset="0.2"/>
				<GradientStop Color="#FF985A5A" Offset="0.9"/>
				<GradientStop Color="#FF787878" Offset="1"/>
			</RadialGradientBrush>

			<LinearGradientBrush x:Key="Led7SegmentBackground" StartPoint="0,0" EndPoint="1,1" PresentationOptions:Freeze="True">
				<GradientStop Color="{x:Static SystemColors.ControlDarkColor}" Offset="0"/>
				<GradientStop Color="{x:Static SystemColors.ControlDarkDarkColor}" Offset="1"/>
			</LinearGradientBrush>

			<SolidColorBrush x:Key="Led7SegmentOff" Color="#FF445644" PresentationOptions:Freeze="True"/>
			<SolidColorBrush x:Key="Led7SegmentOn0" Color="#FF7F7F7F" PresentationOptions:Freeze="True"/>
			<SolidColorBrush x:Key="Led7SegmentOn1" Color="#FF02FD02" PresentationOptions:Freeze="True"/>

			<LinearGradientBrush x:Key="LedMatrixBackground" StartPoint="0.5,0" EndPoint="0.5,1" PresentationOptions:Freeze="True">
				<GradientStop Color="{x:Static SystemColors.ControlDarkColor}" Offset="0"/>
				<GradientStop Color="{x:Static SystemColors.ControlDarkDarkColor}" Offset="1"/>
			</LinearGradientBrush>

			<SolidColorBrush x:Key="LedMatrixOff" Color="#FF1F2B1F" PresentationOptions:Freeze="True"/>

			<LinearGradientBrush x:Key="DisplayBackground" StartPoint="0.25,0" EndPoint="0.75,1" PresentationOptions:Freeze="True">
				<GradientStop Color="{x:Static SystemColors.ControlLightColor}" Offset="0"/>
				<GradientStop Color="{x:Static SystemColors.ControlDarkColor}" Offset="1"/>
			</LinearGradientBrush>

			<SolidColorBrush x:Key="OscilloscopeBackground" Color="Black" PresentationOptions:Freeze="True"/>
			<SolidColorBrush x:Key="OscilloscopeText" Color="#FF7F7F7F" PresentationOptions:Freeze="True"/>
			<SolidColorBrush x:Key="OscilloscopeLine" Color="#FF02FD02" PresentationOptions:Freeze="True"/>

			<LinearGradientBrush x:Key="ConstantBackground" StartPoint="0,0" EndPoint="1,1" PresentationOptions:Freeze="True">
				<GradientStop Color="#FFCFDCDC" Offset="0"/>
				<GradientStop Color="#FF9BB7B7" Offset="1"/>
			</LinearGradientBrush>

			<LinearGradientBrush x:Key="SensorBackground" StartPoint="0,0" EndPoint="1,1" PresentationOptions:Freeze="True">
				<GradientStop Color="#FFDFEFEF" Offset="0"/>
				<GradientStop Color="#FFAFCFCF" Offset="1"/>
			</LinearGradientBrush>

			<LinearGradientBrush x:Key="ClockBackground" StartPoint="0,0" EndPoint="1,1" PresentationOptions:Freeze="True">
				<!--<GradientStop Color="{x:Static SystemColors.ControlLightLightColor}" Offset="0"/>
				<GradientStop Color="{x:Static SystemColors.ControlColor}" Offset="1"/>-->
				<GradientStop Color="#FFDFEFEF" Offset="0"/>
				<GradientStop Color="#FFAFCFCF" Offset="1"/>
			</LinearGradientBrush>

			<LinearGradientBrush x:Key="PinBackground" StartPoint="0,0" EndPoint="1,1" PresentationOptions:Freeze="True">
				<GradientStop Color="#FFCFDCDC" Offset="0"/>
				<!--<GradientStop Color="Red" Offset="0.5"/>-->
				<GradientStop Color="#FF9BB7B7" Offset="1"/>
			</LinearGradientBrush>

			<LinearGradientBrush x:Key="ProbeBackground" StartPoint="0,0" EndPoint="1,1" PresentationOptions:Freeze="True">
				<GradientStop Color="{x:Static SystemColors.ControlLightLightColor}" Offset="0"/>
				<GradientStop Color="{x:Static SystemColors.ControlColor}" Offset="1"/>
			</LinearGradientBrush>

			<LinearGradientBrush x:Key="SoundBackground" StartPoint="0,0" EndPoint="1,1" PresentationOptions:Freeze="True">
				<GradientStop Color="#FF9C9CAA" Offset="0"/>
				<GradientStop Color="#FFCACBD8" Offset="1"/>
			</LinearGradientBrush>

			<LinearGradientBrush x:Key="GraphicsArrayBackground" StartPoint="0,0" EndPoint="1,1" PresentationOptions:Freeze="True">
				<GradientStop Color="{x:Static SystemColors.ControlDarkColor}" Offset="0"/>
				<GradientStop Color="{x:Static SystemColors.ControlDarkDarkColor}" Offset="1"/>
			</LinearGradientBrush>

			<Style x:Key="DialogFixedWindow" TargetType="{x:Type Window}">
				<Setter Property="FlowDirection" Value="{x:Static properties:Resources.FlowDirection}"/>
				<Setter Property="Background" Value="{StaticResource WindowBackground}"/>
				<Setter Property="ResizeMode" Value="NoResize"/>
				<Setter Property="WindowStyle" Value="SingleBorderWindow"/>
				<Setter Property="ShowInTaskbar" Value="False"/>
				<Setter Property="SizeToContent" Value="WidthAndHeight"/>
				<Setter Property="SnapsToDevicePixels" Value="True"/>
			</Style>

			<Style x:Key="DialogWindow" TargetType="{x:Type Window}">
				<Setter Property="FlowDirection" Value="{x:Static properties:Resources.FlowDirection}"/>
				<Setter Property="Background" Value="{StaticResource WindowBackground}"/>
				<Setter Property="ResizeMode" Value="CanResizeWithGrip"/>
				<Setter Property="WindowStyle" Value="SingleBorderWindow"/>
				<Setter Property="ShowInTaskbar" Value="False"/>
				<Setter Property="SizeToContent" Value="Manual"/>
				<Setter Property="MinWidth" Value="320"/>
				<Setter Property="MinHeight" Value="240"/>
				<Setter Property="Width" Value="{Binding Path=WindowLocation.Width, Mode=TwoWay}"/>
				<Setter Property="Height" Value="{Binding Path=WindowLocation.Height, Mode=TwoWay}"/>
				<Setter Property="WindowState" Value="{Binding Path=WindowLocation.WindowState, Mode=TwoWay}"/>
				<Setter Property="SnapsToDevicePixels" Value="True"/>
			</Style>

			<Style TargetType="lc:CommandMenuItem">
				<Setter Property="Header" Value="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}"/>
				<Setter Property="InputGestureText" Value="{Binding RelativeSource={RelativeSource Self}, Path=Command.InputGestureText}"/>
				<Style.Triggers>
					<MultiDataTrigger>
						<MultiDataTrigger.Conditions>
							<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Items.Count}" Value="0"/>
							<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=Command}" Value="{x:Null}"/>
						</MultiDataTrigger.Conditions>
						<Setter Property="IsEnabled" Value="False"/>
					</MultiDataTrigger>
				</Style.Triggers>
			</Style>

			<Style TargetType="{x:Type Label}">
				<Setter Property="Margin" Value="3"/>
				<Setter Property="HorizontalContentAlignment" Value="Right"/>
				<Setter Property="VerticalAlignment" Value="Top"/>
			</Style>

			<Style TargetType="{x:Type Button}">
				<Setter Property="Width" Value="Auto"/>
				<Setter Property="MinWidth" Value="76"/>
				<Setter Property="Margin" Value="8"/>
				<Setter Property="Padding" Value="8,2"/>
			</Style>

			<Style TargetType="{x:Type CheckBox}">
				<Setter Property="Margin" Value="3"/>
				<Setter Property="HorizontalAlignment" Value="Left"/>
				<Setter Property="VerticalAlignment" Value="Center"/>
			</Style>

			<Style TargetType="{x:Type TextBox}">
				<Setter Property="Padding" Value="3,2"/>
				<Setter Property="Margin" Value="3"/>
				<Setter Property="MinWidth" Value="65"/>
				<Setter Property="VerticalAlignment" Value="Center"/>
				<Setter Property="SpellCheck.IsEnabled" Value="True"/>
				<Style.Triggers>
					<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=AcceptsReturn}" Value="True">
						<Setter Property="Margin" Value="3,5"/>
						<Setter Property="VerticalAlignment" Value="Stretch"/>
						<Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
						<Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
						<Setter Property="AcceptsTab" Value="True"/>
					</DataTrigger>
				</Style.Triggers>
			</Style>

			<Style TargetType="ComboBox">
				<Setter Property="Margin" Value="3"/>
				<Setter Property="HorizontalAlignment" Value="Stretch"/>
				<Setter Property="VerticalAlignment" Value="Center"/>
				<Setter Property="MinWidth" Value="65"/>
			</Style>

			<Style TargetType="lc:AutoWidthComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
				<Setter Property="HorizontalAlignment" Value="Left"/>
			</Style>

			<Style TargetType="{x:Type FlowDocument}">
				<Setter Property="FontFamily" Value="{x:Static SystemFonts.MessageFontFamily}"/>
			</Style>

			<Style x:Key="LogicCircuitBackground" TargetType="{x:Type Canvas}">
				<Setter Property="Background" Value="White"/>
				<Style.Triggers>
					<DataTrigger Binding="{Binding Path=ShowGrid}" Value="True">
						<Setter Property="Background">
							<Setter.Value>
								<DrawingBrush Viewport="{x:Static lc:Symbol.LogicalCircuitBackgroundTile}" ViewportUnits="Absolute" TileMode="Tile">
									<DrawingBrush.Drawing>
										<DrawingGroup>
											<GeometryDrawing Brush="White">
												<GeometryDrawing.Geometry>
													<RectangleGeometry Rect="0,0,102,102"/>
												</GeometryDrawing.Geometry>
											</GeometryDrawing>
											<GeometryDrawing Brush="#D0000000">
												<GeometryDrawing.Geometry>
													<GeometryGroup>
														<RectangleGeometry Rect="98,98,4,4"/>
													</GeometryGroup>
												</GeometryDrawing.Geometry>
											</GeometryDrawing>
										</DrawingGroup>
									</DrawingBrush.Drawing>
								</DrawingBrush>
							</Setter.Value>
						</Setter>
					</DataTrigger>
				</Style.Triggers>
			</Style>

			<DrawingBrush x:Key="SliderBackground" PresentationOptions:Freeze="True">
				<DrawingBrush.Drawing>
					<GeometryDrawing>
						<GeometryDrawing.Brush>
							<LinearGradientBrush StartPoint="0,1" EndPoint="1,1">
								<GradientStop Color="{x:Static SystemColors.ControlColor}" Offset="1"/>
								<GradientStop Color="{x:Static SystemColors.ControlLightLightColor}" Offset="0"/>
							</LinearGradientBrush>
						</GeometryDrawing.Brush>
						<GeometryDrawing.Geometry>
							<PathGeometry>
								<PathFigure IsClosed="True">
									<PolyLineSegment Points="100,0 100,-50"/>
								</PathFigure>
							</PathGeometry>
						</GeometryDrawing.Geometry>
					</GeometryDrawing>
				</DrawingBrush.Drawing>
			</DrawingBrush>

			<Style x:Key="CircuitDescriptorGroup" TargetType="GroupItem">
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="GroupItem">
							<Expander IsExpanded="{Binding Path=Items[0].CategoryExpanded}">
								<Expander.Header>
									<TextBlock FontWeight="Bold" Foreground="{x:Static SystemColors.AppWorkspaceBrush}">
										<TextBlock.Style>
											<Style TargetType="TextBlock">
												<Setter Property="Text" Value="{Binding Path=Name}"/>
												<Style.Triggers>
													<DataTrigger Binding="{Binding Path=Name}" Value="">
														<Setter Property="Text" Value="{Binding Path=Items[0].Circuit.CircuitProject.ProjectSet.Project.Name}"/>
													</DataTrigger>
												</Style.Triggers>
											</Style>
										</TextBlock.Style>
									</TextBlock>
								</Expander.Header>
								<Expander.Content>
									<ItemsPresenter/>
								</Expander.Content>
							</Expander>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>

			<!-- Used as header template in controls that support accelerator keys and get content from user input to show underscore rather then use it as a hot key -->
			<DataTemplate x:Key="ignoreHotkey">
				<TextBlock Text="{Binding}"/>
			</DataTemplate>
		</ResourceDictionary>
	</Application.Resources>
</Application>
